/*
	单选
*/
define(
	[
		'require',
		'broada/base/text!./template.hbs'
	],
	function (require) {
		"use strict";

		var forEach = Ember.EnumerableUtils.forEach;
		var tpl = require('broada/base/text!./template.hbs');

		var ServiceRadioView = Ember.Component.extend({
			layout: Ember.HTMLBars.compile(tpl),	
			didInsertElement: function(){
				var ctrl = this.get("controller"),
					view = this;
				var $viewRoot = view.$();
				view.tplData();
				$viewRoot.find("input").click(function(){
					var serverity = $(this).attr("value");
					if(serverity == "all"){
						serverity = undefined;
					}
					ctrl.sendAction("itemClick",serverity);
				});

			},
			tplData:function(){
				var view = this;
				var serRankNums = view.get("serviceNums");
				serRankNums.forEach(function(node){
					switch(node.alarmType){
						case "严重":
						view.set("serious",node.serverCount);
						view.set("seriousValue",node.alarmCode);
						break;
						case "警告":
						view.set("alerts",node.serverCount);
						view.set("alertsValue",node.alarmCode);
						break;
						case "提醒":
						view.set("remind",node.serverCount);
						view.set("remindValue",node.alarmCode);
						break;
					}
				});
			}
		});

		APM.ui.ServiceRadioView = ServiceRadioView;

		return ServiceRadioView;
	}
);